package com.wuye.repository;

import com.wuye.model.MenuActivity;
import com.wuye.model.customer.CustomerDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by zhanchi on 2016/6/30.
 */
public interface CustomerRepository extends JpaRepository<CustomerDetail,String> {
    @Query(nativeQuery = true,value="select wuye_customerOption_id,wuye_customerOption_name,date_format(wuye_customerOption_releaseTime,'%Y-%m-%d') from customerOption where customerOption.wuye_customerOption_status = 1")
    public List<Object[]> findCusName();
    @Query(nativeQuery = true,value="select wp.wuye_optionPoll_id,wp.wuye_optionPoll_name,date_format(wp.wuye_optionPoll_createTime,'%Y-%m-%d'),wo.wuye_optionDetail_id," +
            "wo.wuye_optionDetail_name,wo.wuye_optionDetail_parentId,wo.wuye_optionDetail_parentName," +
            "wo.wuye_optionDetail_opName1,wo.wuye_optionDetail_opName2,wo.wuye_optionDetail_opName3,wo.wuye_optionDetail_opName4," +
            "wo.wuye_optionDetail_opName5,wo.wuye_optionDetail_opName6,wo.wuye_optionDetail_opName7,wo.wuye_optionDetail_opName8 " +
            "from (customerOption cu left join wuye_optionPoll wp on cu.wuye_customerOption_pollId=wp.wuye_OptionPoll_id) " +
            "left join wuye_optionDetail wo on wp.wuye_OptionPoll_id = wo.wuye_optionDetail_pollId where cu.wuye_customerOption_id = ?1")
    public List<Object[]> findAllCustomer(String id);
//    @Query(nativeQuery = true,value="select wo.wuye_optionDetail_id,wo.wuye_optionDetail_name from wuye_optionDetail wo left join customerOption cu on where wo.wuye_optionDetail_parentId is null")
//    public List<Object[]> findFirst();
}
